//
// Created by root on 2/23/18.
//

#ifndef FUNNY_TRANSLATOR_GLOBAL_H
#define FUNNY_TRANSLATOR_GLOBAL_H

#include "../ds/datastructure.h"
#include "../fa/automata.h"


#define FUNNY_FILE_EXTENSION   ".fn"
#define SCHEME_FILE_EXTENSION  ".scm"

#define COMPONENT_FILE       "component.fn"
#define COMPONENT_META_FILE  "component.meta"

#define NIL_DEF         "NIL"
#define FUNNY_HOME      "FUNNY_HOME"

typedef Statement *(*Parser)(char *funny);
typedef char * (*MacroFunc0)();
typedef char * (*MacroFunc1)(struct _Statement *);
typedef char * (*MacroFunc2)(struct _Statement *, struct _Statement *);
typedef char * (*MacroFunc3)(struct _Statement *, struct _Statement *, struct _Statement *);
typedef char * (*MacroFunc4)(struct _Statement *, struct _Statement *, struct _Statement *, struct _Statement *);


typedef struct _Funny {
    const char *homeDir;
    const char *cwd;  //current working directory
    const char *component;
    const char *repositories;

    String *repoPaths; //split from repositories
    Map componentPaths; //name -> basePath

    Map macros;

    Map rules; //cache for lexer
    String *lexOrders;

    Trie *mappingTrie; //cache for fp functions
    Tree *inheritance; //cache for oop classes
    Map oopCodes; //cache for oop templates

    //component metadata
    Graph *components;
    Queue *modules;
    Queue *functions;
    Queue *dependencies;
    Queue *executables;
} Funny;

Funny *globalFunny;
Parser parser;
MacroFunc1 matcher;

#endif //FUNNY_TRANSLATOR_GLOBAL_H
